package com.test.mylotterysystem.controller;

import com.test.mylotterysystem.comment.utils.MyBeanUtil;
import com.test.mylotterysystem.controller.Param.ActivityCreateParam;
import com.test.mylotterysystem.controller.Param.PageParam;
import com.test.mylotterysystem.controller.Result.ActivityCreateResult;
import com.test.mylotterysystem.controller.Result.ActivityListResultDTO;
import com.test.mylotterysystem.controller.Result.GetActivityResult;
import com.test.mylotterysystem.service.ActivityService;
import com.test.mylotterysystem.service.DTO.ActivityCreateResultDTO;
import com.test.mylotterysystem.service.DTO.ActivityResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/activity")
@RestController
@Slf4j
public class ActivityController {
    @Autowired
    private ActivityService activityService;

    /**
     * 创建活动
     *
     * @param activityCreateParam
     * @return
     */
    @RequestMapping("/createActivity")
    public ActivityCreateResult createActivity(@Validated @RequestBody ActivityCreateParam activityCreateParam) {
        log.info("activityCreateParam为：{}", activityCreateParam);
        ActivityCreateResultDTO activityCreateResultDTO = activityService.createActivity(activityCreateParam);

        return MyBeanUtil.transOfActivityCreateResult(activityCreateResultDTO);
    }

    /**
     * 获取活动列表
     *
     * @param pageParam
     * @return
     */
    @RequestMapping("/getActivityList")
    public GetActivityResult getActivityList(PageParam pageParam) {
        log.info("pageParam为：{}", pageParam);
        ActivityListResultDTO<ActivityResultDTO> activityListResultDTO = activityService.getActivityList(pageParam);
        return MyBeanUtil.transOfGetActivityResult(activityListResultDTO);
    }
}
